package com.hzvtc.bosswang.manageeducation.controller;


import com.hzvtc.bosswang.managecommon.domain.AjaxResult;
import com.hzvtc.bosswang.manageeducation.domain.UserCourse;
import com.hzvtc.bosswang.manageeducation.service.UserCourseService;
import com.hzvtc.bosswang.manageservice.api.UserApi;
import com.hzvtc.bosswang.manageservice.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/edu-manager")
public class UserCourseController {

    @Autowired
    private UserCourseService userCourseService;


    @GetMapping("/view-selected-students/{id}")
    public AjaxResult viewSelectedStudents(@PathVariable Long id){
        ArrayList<User> users = userCourseService.selectStudentsByCourseId(id);
        return new AjaxResult(200,"查询成功",users);

    }

    @PostMapping("/check-score")
    public AjaxResult checkScore(@RequestBody UserCourse userCourse){
        Integer res = userCourseService.editUserCourse(userCourse);
        if (res>0) {
            return new AjaxResult(200, "打分成功",null);
        }
        return new AjaxResult(500,"打分失败",null);
    }
}
